﻿using System;
using System.Linq;
using System.Collections.Generic; 
using System.Data;
using Matrix.Common.Utility;
using Matrix.MaKaYunShang.Model;
using Matrix.MaKaYunShang.DAL;

namespace Matrix.MaKaYunShang.BLL
{
	public partial class OrderTrackingBLL : BaseBLL<OrderTrackingBLL>
	{
		#region 默认方法
		/// <summary>
		/// 增加一条数据
		/// </summary>
		public int  Add(OrderTracking model)
		{
			return OrderTrackingDAL.Instance.Add(model);		
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(OrderTracking model)
		{
			return OrderTrackingDAL.Instance.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int Id)
		{			
			return OrderTrackingDAL.Instance.Delete(Id);
		}
				/// <summary>
		/// 批量删除一批数据
		/// </summary>
		public bool DeleteList(string Idlist )
		{
			return OrderTrackingDAL.Instance.DeleteList(Idlist );
		}
		
		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public OrderTracking GetModel(int Id)
		{
			var ds = OrderTrackingDAL.Instance.GetModel(Id);
            return ds == null ? null : ServicesHelper.DataSetToIList<OrderTracking>(ds).ToList()[0];
		}
		
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<OrderTracking> GetModelList(string strWhere = null)
		{
			var ds = OrderTrackingDAL.Instance.GetList(strWhere);
			return ServicesHelper.DataSetToIList<OrderTracking>(ds).ToList();
		}
		#endregion
		
		#region 扩展方法

	    /// <summary>
	    /// 通过订单ID获取订单轨迹列表
	    /// </summary>
	    public List<OrderTracking> GetOrderTrackByOrderId(int orderId)
	    {
	        return OrderTrackingDAL.Instance.GetOrderTrackByOrderId(orderId);
	    }

	    /// <summary>
	    /// 通过订单ID以及前置状态、后置状态 查询是否有相同订单轨迹记录
	    /// </summary>
	    /// <param name="orderId"></param>
	    /// <param name="preOrderStatus"></param>
	    /// <param name="orderStatus"></param>
	    /// <returns></returns>
	    public int CheckExsitOrderSameTracking(int orderId, int preOrderStatus, int orderStatus)
	    {
	        return OrderTrackingDAL.Instance.CheckExsitOrderSameTracking(orderId, preOrderStatus, orderStatus);
	    }
		#endregion
	}
}